package com.example.tnot.Teacher.MinePart.InternalFragment.notebook.adapter;

import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.MinePart.InternalFragment.notebook.ItemBean.folder;
import com.example.tnot.Util.ToastUtil;

import java.util.List;

public class FolderAdapter extends RecyclerView.Adapter<FolderAdapter.ViewHolder>{
    private List<folder> list;
    public FolderAdapter(List<folder> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public FolderAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.item_rv_mine_notebook_itemlist, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull FolderAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
        holder.tv_content.setText(list.get(position).getContent());
        holder.iv_icon.setImageResource(list.get(position).getImageView());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ToastUtil.showCustomToast(holder.itemView.getContext(),"点击了"+list.get(position).getContent());
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tv_content;
        ImageView iv_icon;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_content = itemView.findViewById(R.id.tv_content);
            iv_icon = itemView.findViewById(R.id.iv_icon);
        }
    }
}
